package com.itheima.springbootsecurity.interceptors;

import com.itheima.springbootsecurity.utils.ThreadLocalUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * @author wuhaohua
 */
@Component
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        // 当请求完成后，清空ThreadLocal数据
        ThreadLocalUtil.remove();

        HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
    }
}
